package com.stable.job;

import com.stable.service.NewFinanceService;
import com.stable.service.StockBasicService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

//import com.stable.service.ETFBasicService;

//import com.stable.service.ETFBasicService;

/**
 * 这是我们的测试job类
 *
 * @author
 * @date 2018/10/25.
 */
@Component
@Log4j2
public class ZwJob {
//    private int period = 60;
//    private final ScheduledExecutorService scheduledExecutorService = new ScheduledThreadPoolExecutor(1);

    @Autowired
    private NewFinanceService newFinanceService;
    @Autowired
    private StockBasicService stockBasicService;
//    @Autowired
//    private ETFBasicService etfBasicService;
//    @Autowired
//    private ConceptBoardService conceptBoardService;

    @Scheduled(cron = "${refresh.cron:0 0 17 ? * 1,2,3,4,5}")
    private void dailyJobProBar() {
        // 每天同步日线收盘数据，包含250线
        stockBasicService.jobSynStockProBar("", false, "", 2);
    }


    @Scheduled(cron = "${refresh.cron:0 20 18 ? * 1,2,3,4,5}")
    private void dailyJobETFAndConceptBoard() {
        //每天同步ETF top 30数据，并找到最近20天内最活跃的15个ETF
//        etfBasicService.jobSynStockETFTop30();
        //每天同步概念 top 20数据，找到最近15天内最活跃的10个概念
//        conceptBoardService.jobSynStockConceptBoardTop20();
    }

    @Scheduled(cron = "${refresh.cron:0 0 18 ? * 5}")
    private void weekJob() {
        //更新股票列表到redis
        stockBasicService.jobSynCodeList();
        //更新财务年报
        newFinanceService.jobSynStockNewFinance();
    }


    // 每月最后一天
    @Scheduled(cron = "${refresh.cron:0 30 18 28-31 * ?}")
    private void day5update() {
        //根据同花顺更新公司亮点及质押等数据信息
        stockBasicService.jobSynCodeTopic();

    }

//    @PostConstruct
//    private void start() {
//        scheduledExecutorService.scheduleAtFixedRate(() -> {
//
//        }, 2, period, TimeUnit.SECONDS);
//    }

}
